
import request from '@/utils/request'
/**
 * 获取某个频道下的文章列表
 * @param {*} channelId 频道id
 * @param {*} timestamp 时间戳，请求新的推荐数据传当前的时间
 */
export const getArticles = (channelId, timestamp) => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params: {
      channel_id: channelId, // 频道id
      timestamp: timestamp, // 时间戳整数 单位毫秒
      with_top: 1
    }
  })
}
/**
 * @description: 不感兴趣文章
 * @param {String} articleId  文章id
 * @return {*}
 */
export const dislikeArticle = (articleId) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}
/**
 * 举报文章
 * @param {*} articleId 文章编号
 * @param {*} type 举报类型编号
 */
export const reportArticle = (articleId, type) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type
    }
  })
}
/**
 * @description: 获取文章详情
 * @param {*} id 文章id
 * @return {*}
 */
export const getArticle = id => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${id}`
  })
}
/**
 * @description: 关注
 * @param {*} userId 用户id
 * @return {*}
 */
export const followUser = (userId) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

/**
 * @description: 取消关注
 * @param {*} userId 用户id
 * @return {*}
 */

export const unFollowUser = (userId) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${userId}`
  })
}
/**
 * @description: 取消点赞
 * @param {*} id
 * @return {*}
 */
export const delLike = id => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${id}`
  })
}

/**
 * @description: 添加点赞
 * @param {*} id
 * @return {*}
 */
export const addLike = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}
